package com.onstar.cn.api;

import com.onstar.cn.api.framework.ClazzInjectUtils;
import com.onstar.cn.api.framework.annotation.Path;
import com.onstar.cn.api.framework.annotation.RequestMapping;
import com.onstar.cn.sqlite.entities.RequestEventReportEntity;
import com.onstar.cn.framework.network.entity.RequestEntity;

/**
 * @author Xiaofeng Feng
 * @Title: OperateReportService.java
 * @Description:事件上传report
 * @date 2015年8月19日 下午2:15:18
 */
@Path("/api/v1/data")
public class OperateDAAPReportService {
    /*
     * [{"id":0,"functionID":"F0001","timestamp":"2015-07-28 16:47:08"
     * ,"vin":"hhhhhhhh","operation":"click","startTimestamp":
     * "2015-07-28 16:47:08","endTimestamp":"2015-07-28 16:47:08"
     * ,"content":"content","role":"owner"},
     * {"id":0,"functionID":"F0002","timestamp":"2015-07-28 16:47:08"
     * ,"vin":"hhhhhhhh","operation":"click","startTimestamp":
     * "2015-07-28 16:47:08","endTimestamp":"2015-07-28 16:47:08"
     * ,"content":"content","role":"owner"}]
     */
    private String serverURL;

    public OperateDAAPReportService(String serverURL) {
        this.serverURL = serverURL;
    }

    @RequestMapping("/upload")
    public RequestEntity operateDAAPReport(RequestEntity requestEntity, RequestEventReportEntity EventReportList) {
        if (requestEntity == null) {
            requestEntity = new RequestEntity();
        }
        String url = ClazzInjectUtils.injectUrl(getClass(), "operateDAAPReport", requestEntity, EventReportList);
        //this is for test;
//        url="http://113.52.176.223:53611/daap/api/v1/data/upload";
//        url="https://m-idt2.onstar.com.cn/daap/api/v1/data/upload";
//        requestEntity.setUrl(url);
        requestEntity.setUrl(serverURL + url);
        requestEntity.setBody(EventReportList.getDaapContent());
        return requestEntity;
    }

}
